package net.fdukedom.epicurus.client.ui.dialogs;

import java.awt.Component;

import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class ModalDialog extends JDialog {

	private static final long serialVersionUID = 1L;

	public ModalDialog(JFrame frame) {
		super(frame, true);
	}

	public ModalDialog(JFrame frame, JPanel panel, String title) {
		super(frame, true);
		setContentPane(panel);
		init(title, frame);
	}
	
	public ModalDialog(JDialog dlg, JPanel panel, String title) {
		super(dlg, true);
		setContentPane(panel);
		init(title, dlg);
	}

	protected void init(String title, Component component) {
		pack();
		setTitle(title);
		setResizable(false);
		setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
		setLocationRelativeTo(component);
	}

	/**
	 * Close dialog
	 */
	protected void close() {
		this.dispose();
	}
}
